﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once
#include "IGeometry.h"


namespace gcmp
{
    class ICurve3d;
    class Vector3d;
    class Intervald;
    class INurbsSurface;

    /// \brief 曲面
    ///
    class ISurface : public IGeometry
    {
        DEFINE_CAST_DERIVED(gcmp::ISurface, gcmp::IGeometry);
    public:
        /// \brief    获得曲面U向参数域
        /// \return   U向参数域
        virtual Intervald GetLimitU() const = 0;

        /// \brief    获得曲面V向参数域
        /// \return   V向参数域
        virtual Intervald GetLimitV() const = 0;

        /// \brief   曲面的U向是否封闭
        /// \return  封闭返回True，不封闭返回False
        virtual bool IsClosedU() const = 0;

        /// \brief     曲面的V向是否封闭
        /// \return    封闭返回True，不封闭返回False
        virtual bool IsClosedV() const = 0;

        /// \brief  得到曲面上u，v参数处的坐标点
        /// \param dU  u参数
        /// \param dU  v参数
        /// \return  坐标点
        virtual Vector3d GetPoint(double dU, double dV) const = 0;

        /// \brief  得到曲面上u，v参数处的法矢
        /// \param dU  u参数
        /// \param dU  v参数
        /// \return    法矢
        virtual Vector3d GetNormal(double dU, double dV) const = 0;

        /// \brief  根据坐标点计算对应的参数值
        /// \param pointOnSurface 坐标点
        /// \param dU U参数，要求必须初始化
        /// \param dV V参数，要求必须初始化
        /// \param distanceEpsilon 距离容差
        virtual bool GetParameter(const Vector3d &pointOnSurface, double &dU, double &dV, double distanceEpsilon) const = 0;

        /// \brief  计算曲面在参数u,v处的切向
        /// \param u U参数
        /// \param v V参数
        /// \param tangentU U方向的切向
        /// \param tangentV V方向的切向
        /// \return  成果返沪true，否则返回false
        virtual bool GetTangent(double u,double v,Vector3d &tangentU,Vector3d &tangentV) const = 0;

        /// \brief  创建等U线
        /// \param uParameter U参数
        /// \return 等U线
        virtual OwnerPtr<ICurve3d> CreateUIsoParamCurve(double uParameter) const = 0;

        /// \brief  产生等V线
        /// \param vParameter V参数
        /// \return V等参线
        virtual OwnerPtr<ICurve3d> CreateVIsoParamCurve(double vParameter) const = 0;

        /// \brief  计算曲面在参数u,v处的高斯曲率
        /// \param u U参数
        /// \param v V参数
        /// \param gaussCurvature 计算出的高斯曲率值
        /// \return  成功返回true，否则返回false
        virtual bool GaussCurvature(double u, double v, double& gaussCurvature) const = 0;

        /// \brief  计算曲面在参数u,v处的平均曲率
        /// \param u U参数
        /// \param v V参数
        /// \param meanCurvature 计算出的平均曲率值
        /// \return  成功返回true，否则返回false
        virtual bool MeanCurvature(double u, double v, double& meanCurvature) const = 0;

        /// \brief  转换为NurbsSurface
        virtual OwnerPtr<INurbsSurface> ToNurbsSurface()const = 0;
    public:
        virtual ~ISurface() {}

    };
}
